using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Data;

namespace Test.Support {
	class NdtsSumFix {

		static void MainX() {


			DAL dal=new DAL("pon-wpsq16-db","directory");

			foreach(FileInfo inf in new DirectoryInfo(@"\\pon-wpwb02-cl01\c$\Inetpub\ftproot\NDTS\Archive").GetFiles())
			{



				string[] lines=File.ReadAllLines(inf.FullName);
				foreach(string line in lines)
				{
					string[] arr=line.Split(',');
					string prcId=Regex.Match(arr[1],"=\\(\"(\\d+?)\"\\)").Groups[1].Value;

					string sdat=arr[25]+arr[26];
					string boxset=arr[28];
					DateTime ddat=DateTime.ParseExact(sdat,"dd/MM/yyHHmm",null);
					//int rec=(int)dal.Scalar("select count(*) from dirndtsparcel where ParcelID ='{0}' and PromisedFor is null",prcId);
					//if(rec==1)
					{
						int updated=dal.NonQry("update dirndtsparcel set boxset='{2}', PromisedFor=convert(datetime,'{1:yyyy-MM-dd HH:mm:ss}',20) where ParcelID ='{0}' and PromisedFor is null",prcId,ddat,boxset);
					}
				}
			}


		}


	}
}
